﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<script src="~/lib/layui/layui.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>


    <div class="layui-inline">
        <div class="layui-inline">
            <div class="layui-input-group">
                <div class="layui-input-split layui-input-prefix">
                    仓库编码
                </div>
                <input type="text" placeholder="请输入" class="layui-input" style="width:500px" id="stashNum" />
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-form" onclick="Automatic()">
                <input type="checkbox" name="CCC" title="自动生成|关闭自动生成" lay-skin="switch" class="GMon" value="1">
            </div>
        </div>
    </div>
    <br />
    <br />
    <div class="layui-input-group">
        <div class="layui-input-split layui-input-prefix">
            仓库名称
        </div>
        <input type="text" placeholder="请输入" class="layui-input" style="width:500px" id="stashName" />
    </div>
    <br />
    <div class="layui-input-group">
        <div class="layui-input-split layui-input-prefix">
            面积
        </div>
        <input type="text" placeholder="请输入" class="layui-input" style="width:500px" id="area" />
    </div>
    <br />
    <div class="layui-input-group">
        <div class="layui-input-split layui-input-prefix">
            负责人
        </div>
        <input type="text" placeholder="请输入" class="layui-input" style="width:500px" id="chargeName" />
    </div>
    <br />
      <div class="layui-input-group">
        <div class="layui-input-split layui-input-prefix">
            位置
        </div>
        <textarea name="" placeholder="多行文本框" class="layui-textarea" style="width:500px" id="position"></textarea>
    </div>
    <br />
      <div class="layui-input-group">
        <div class="layui-input-split layui-input-prefix">
            备注
        </div>
        <textarea name="" placeholder="多行文本框" class="layui-textarea" style="width:500px" id="warehouseNote"></textarea>
    </div>
    <br />
    <div>
        <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="Stach()">添加</button>
    </div>



</body>
</html>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->



<script>

    //自动生成
    function Automatic(){

      
        var gh = $('.GMon:checked').val()
        console.log(gh);
      
        if (gh==1) {
            var Encoding = "MG" + Math.random().toString().substring(2, 6);

            $("#stashNum").val(Encoding)
        }
        if (gh!=1) {
            $("#stashNum").val('');
        }
    }

        ///仓库添加

    function Stach() {

        var date = {

            stashNum: $("#stashNum").val(),
            stashName: $("#stashName").val(),
            chargeName: $("#chargeName").val(),
            area: $("#area").val(),
            position: $("#position").val(),
            warehouseNote: $("#warehouseNote").val(),
            isyes:0,
            stashId: 0,
            twoDimensionalCode: "",
        };

        console.log(date, '111111111')
        $.ajax({
            url: '@ViewBag.FoundationWrite'+ "/api/Jocker/warehouseCreate",
            type:'post',
            data: JSON.stringify(date),
            dataType:"json",
            contentType: "application/json",
            success: res => {
                if (res.code > 0) {
                    alert("添加成功");    
                    layer.close(layer.index); //它获取的始终是最新弹出的某个层，值是由layer内部动态递增计算的
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭 
                }
                else {

                }

            }

        })


    
    }











</script>



